<?php
/* 
    Created on : 2016-3-20, 16:48:22
    Author     : dongtao <dongtao@xiaomi.com>
*/

/**
 * 根据PHP各种类型变量生成唯一标识号
 * @param type $mix
 * @return string
 */
function genObjectId($mix)
{
    if (is_object($mix) && function_exists('spl_object_hash'))
    {
        return spl_object_hash($mix);
    }
    elseif (is_resource($mix))
    {
        $mix = get_resource_type($mix) . strval($mix);
    }
    else
    {
        $mix = serialize($mix);
    }
    return md5($mix);
}

// 二维数组根据某个字段返回新数组
function arrayMap($arr,$key) {
    $new_array = array();
    foreach ($arr as $k => $val) {
        $new_array[$val[$key]] = $val;
    }
    return $new_array;
}

